home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / public / fax / src / faxd / Everex.h < prev    next >
C/C++ Source or Header  |  1994-08-01  |  5KB  |  123 lines

  1. /*    $Header: /usr/people/sam/fax/faxd/RCS/Everex.h,v 1.44 1994/04/08 03:49:33 sam Rel $ */
  2. /*
  3.  * Copyright (c) 1990, 1991, 1992, 1993, 1994 Sam Leffler
  4.  * Copyright (c) 1991, 1992, 1993, 1994 Silicon Graphics, Inc.
  5.  *
  6.  * Permission to use, copy, modify, distribute, and sell this software and 
  7.  * its documentation for any purpose is hereby granted without fee, provided
  8.  * that (i) the above copyright notices and this permission notice appear in
  9.  * all copies of the software and related documentation, and (ii) the names of
  10.  * Sam Leffler and Silicon Graphics may not be used in any advertising or
  11.  * publicity relating to the software without the specific, prior written
  12.  * permission of Sam Leffler and Silicon Graphics.
  13.  * 
  14.  * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 
  15.  * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 
  16.  * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  
  17.  * 
  18.  * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
  19.  * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
  20.  * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  21.  * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF 
  22.  * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 
  23.  * OF THIS SOFTWARE.
  24.  */
  25. #ifndef _EVEREX_
  26. #define    _EVEREX_
  27. /*
  28.  * ``Old'' Everex Class 1-style Modem Driver.
  29.  */
  30. #include "FaxModem.h"
  31. #include <setjmp.h>
  32.  
  33. class EverexModem : public FaxModem {
  34. private:
  35.     enum ModemType {        // FaxModemType
  36.     UNKNOWN,
  37.     EV958,            // old Everex 4800 baud
  38.     EV968,            // new Everex 9600 baud
  39.     ABATON,            // generic for EV958 or EV968
  40.     };
  41.     ModemType    type;            // deduce modem type
  42.     fxBool    is2D;            // page being sent/recvd has 2D data
  43.     fxBool    prevPage;        // a previous page was received
  44.     fxBool    pageGood;        // quality of last page received
  45.     u_int    dis;            // current remote DIS
  46.     Class2Params params;        // current params during send
  47.     fxStr    lid;            // local id string in modem format
  48. // for reception
  49.     int        shdata;            // current input byte
  50.     int        shbit;            // bit mask for current input byte
  51.     jmp_buf    recvEOF;        // for unexpected EOF on recv
  52.  
  53.     static int modemRateCodes[8];    // map Class 2 to modem parameter
  54.     static int modemScanCodes[8];    // map Class 2 to modem parameter
  55.     static u_int modemPFMCodes[8];    // map Class 2 to T.30 FCF code
  56.     static const u_int modemPPMCodes[8];// map T.30 FCF to Class 2 PPM
  57.  
  58. // modem setup and configuration
  59.     fxBool    setupModem();
  60. // send support
  61.     fxBool    sendTraining(Class2Params& params, fxStr& emsg);
  62.     fxBool    dropToNextBR(Class2Params& params);
  63.     fxBool    waitForCarrierToDrop(fxStr& emsg);
  64.     fxBool    sendPPM(int ppm, fxStr& emsg);
  65.     fxBool    sendPage(TIFF* tif, const Class2Params&, fxStr& emsg);
  66.     fxBool    sendRTC(fxBool is2D);
  67. // receive support
  68.     fxBool    recvIdentification(u_int f1, u_int f2, fxStr& emsg);
  69.     fxBool    recvDCSFrames(const char* cp, u_int& fcf);
  70.     fxBool    recvTSI();
  71.     fxBool    recvDCS();
  72.     fxBool    recvNSS();
  73.     fxBool    recvTraining();
  74.     fxBool    recvPageData(TIFF*, fxStr& emsg);
  75.     void    recvDone(TIFF*, u_long totbytes, u_long nrows,
  76.             u_long bad, int maxbad);
  77.     void    recvCode(int& len, int& code);
  78.     int        recvBit();
  79.     fxBool    recvPPM(int& ppm, fxStr& emsg);
  80.     fxBool    processPPM(const char* buf, int& ppm, fxStr& emsg);
  81. // miscellaneous
  82.     fxBool    modemFaxConfigure(int bits);
  83.     void    encodeCSI(fxStr& binary, const fxStr& ascii);
  84.     void    decodeCSI(fxStr& ascii, const fxStr& binary);
  85. // HDLC frame support
  86.     fxBool    sendFrame(int f1);
  87.     fxBool    sendFrame(int f1, int f2);
  88.     fxBool    sendFrame(int f1, int f2, int f3);
  89.     fxBool    setupFrame(int f, int v);
  90.     fxBool    setupFrame(int f, const char* v);
  91.     fxBool    recvFrame(long ms = 10*1000);
  92. public:
  93.     EverexModem(FaxServer& s, const ModemConfig&);
  94.     virtual ~EverexModem();
  95.  
  96. // send support
  97.     void    sendBegin();
  98.     CallStatus    dialResponse();
  99.     fxBool    getPrologue(Class2Params&, u_int& nsf, fxStr&, fxBool& hasDoc);
  100.     void    sendSetupPhaseB();
  101.     fxBool    sendPhaseB(TIFF* tif, Class2Params&, FaxMachineInfo&,
  102.             fxStr& pph, fxStr& emsg);
  103.     void    sendEnd();
  104.  
  105. // receive support
  106.     CallType    answerCall(AnswerType, fxStr& emsg);
  107.     fxBool    recvBegin(fxStr& emsg);
  108.     fxBool    recvPage(TIFF*, int& ppm, fxStr& emsg);
  109.     fxBool    recvEnd(fxStr& emsg);
  110.  
  111. // polling support
  112.     fxBool    requestToPoll();
  113.     fxBool    pollBegin(const fxStr& pollID, fxStr& emsg);
  114.  
  115. // miscellaneous
  116.     fxBool    dataService();            // establish data service
  117.     fxBool    reset(long ms = 5*1000);    // reset modem
  118.     fxBool    abort(long ms = 5*1000);    // abort session
  119.     void    setLID(const fxStr& number);    // set local id string
  120.     fxBool    supportsEOLPadding() const;    // modem supports EOL padding
  121. };
  122. #endif /* _EVEREX_ */
  123.